package learnTengo

import (
	"fmt"
	"github.com/d5/tengo"
)

func Example1Main() {
	script := tengo.NewScript([]byte(`a := b + 20`))

	_ = script.Add("b", 10)

	c, err := script.Compile()
	if err != nil {
		panic(err)
	}

	if err := c.Run(); err != nil {
		panic(err)
	}

	a := c.Get("a")
	fmt.Println(a.Int())

	if err := c.Set("b", 20); err != nil {
		panic(err)
	}
	if err := c.Run(); err != nil {
		panic(err)
	}
	fmt.Println(c.Get("a").Int())
}
